package tech.lq0.dreamaticvoyage.network;

import net.minecraftforge.network.NetworkDirection;
import net.minecraftforge.network.NetworkRegistry;
import net.minecraftforge.network.simple.SimpleChannel;
import tech.lq0.dreamaticvoyage.Utils;
import tech.lq0.dreamaticvoyage.network.packet.*;

import java.util.Optional;

public class DmvNetwork {

    public static final String NETWORK_VERSION = "1.0";
    public static final SimpleChannel CHANNEL = NetworkRegistry.newSimpleChannel(Utils.loc("network"),
            () -> NETWORK_VERSION, NETWORK_VERSION::equals, NETWORK_VERSION::equals);

    public static void init() {
        CHANNEL.registerMessage(0, LeviyLaunchPacket.class, LeviyLaunchPacket::encode, LeviyLaunchPacket::decode, LeviyLaunchPacket::handle);
        CHANNEL.registerMessage(1, PhantasmalVoyagerPacket.class, PhantasmalVoyagerPacket::encode, PhantasmalVoyagerPacket::decode, PhantasmalVoyagerPacket::handle);
        CHANNEL.registerMessage(2, ContainerDataSyncPacket.class, ContainerDataSyncPacket::encode, ContainerDataSyncPacket::decode, ContainerDataSyncPacket::handle, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
        CHANNEL.registerMessage(3, OminousWavePacket.class, OminousWavePacket::encode, OminousWavePacket::decode, OminousWavePacket::handle);
        CHANNEL.registerMessage(4, FukamizuFermenterSyncPacket.class, FukamizuFermenterSyncPacket::encode, FukamizuFermenterSyncPacket::decode, FukamizuFermenterSyncPacket::handle, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
        CHANNEL.registerMessage(5, ContainerComponentDataSyncPacket.class, ContainerComponentDataSyncPacket::encode, ContainerComponentDataSyncPacket::decode, ContainerComponentDataSyncPacket::handle, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
    }
}
